﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;

namespace MobileDesigner.Models
{
    public class MobileDesignerContext : DbContext
    {
        public MobileDesignerContext()
            : base("mobileDesignerDb")
        {
        }

        public DbSet<User> Users { get; set; }
        public DbSet<Project> Projects { get; set; }
        public DbSet<ProjectAssociate> ProjectAssociates { get; set; }
    }

    [Table("User")]
    public class User
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public int SuperiorID { get; set; }
        public string Name { get; set; }
        public string LastName { get; set; }
    }

    [Table("Project")]
    public class Project
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        public string Location { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
    }

    [Table("ProjectAssociate")]
    public class ProjectAssociate
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        [ForeignKey("User")]
        public int UserID { get; set; }
        public virtual User User { get; set; }
        [ForeignKey("Project")]
        public int ProjectID { get; set; }
        public virtual Project Project { get; set; }
    }
}